using System;
using DevExpress.Xpo;

namespace POI.eTransmittal.Enitity
{
    [OptimisticLocking(false), DeferredDeletion(false)]
    public class User : XPCustomObject
    {
        [Key]
        public string UserID;

        public Role Role;
        public TransmittalUser PremierOilUser;

        #region AuditTrail

        public DateTime CreatedDate;

        public string CreatedBy;

        public DateTime LastChangedDate;

        public string LastChangedBy;

        public void Save(string userId)
        {
            if (CreatedBy == null || CreatedDate == DateTime.MinValue)
            {
                this.CreatedDate = DateTime.Now;
                this.CreatedBy = userId;
            }

            this.LastChangedDate = DateTime.Now;
            this.LastChangedBy = userId;

            this.Save();
        }

        #endregion

        public User()
            : base()
        {
            // This constructor is used when an object is loaded from a persistent storage.
            // Do not place any code here.
        }

        public User(Session session)
            : base(session)
        {
            // This constructor is used when an object is loaded from a persistent storage.
            // Do not place any code here.
        }

        public override void AfterConstruction()
        {
            base.AfterConstruction();
            // Place here your initialization code.
        }
    }

}